package com.zhang.spring;

import com.zhang.spring.bean.Cat;
import com.zhang.spring.bean.Person;
import com.zhang.spring.config.MainConfig;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class AnnotationMainTest {
	public static void main(String[] args) {
		AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(MainConfig.class);
		//Person bean = applicationContext.getBean(Person.class);
		//System.out.println(bean);
		/*String[] names = applicationContext.getBeanDefinitionNames();
		for (String name : names){
			System.out.println(name);
		}*/

	/*	Cat cat = applicationContext.getBean(Cat.class);
		Cat cat1 = applicationContext.getBean(Cat.class);
		System.out.println(cat==cat1);

		Person person = applicationContext.getBean(Person.class);
		Cat cat2 = person.getCat();
		Person person1 = applicationContext.getBean(Person.class);
		Cat cat3 = person1.getCat();
		System.out.println(person==person1);
		System.out.println(cat2==cat3);*/

		Person person = applicationContext.getBean(Person.class);
		ApplicationContext applicationContext1 = person.getApplicationContext();
		System.out.println(applicationContext1==applicationContext);

	}
}
